<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ page import="java.util.*, com.shopcart.controller.*, com.shopcart.entity.*"%>

<% 
	List<Cart> carts = ((CartController) session.getAttribute("cartController")).getCarts((Customer) session.getAttribute("customer"));
	request.setAttribute("carts", carts);
%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="bootstrap/css/bootstrap.min.css" rel="stylesheet"
	media="screen" />
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script src="bootstrap/js/bootstrap.min.js"></script>

<title>BOUN SHOP</title>
</head>
<body>
	<div class="navbar navbar-inverse">
		<div class="navbar-inner">
			<a class="brand" href="home.jsp">BOUN SHOP</a>
			<ul class="nav">
				<li><a href="home.jsp">Home</a></li>
				<!-- 
				 -->
				<li><a href="cart.jsp">My Cart</a></li>
				<li class="active"><a href="history.jsp">My History</a></li>
			</ul>
			<ul class="nav pull-right">
				<li><button type="button" class="btn btn-success" onclick="">Checkout</button></li>
				<li class="divider-vertical"></li>
				<li><button type="button" class="btn btn-danger"
						onclick="logout();">Log Out</button></li>
			</ul>
		</div>
	</div>

	<div class="container">
		<table class="table table-striped">
			<thead>
				<tr>
					<th>Date</th>
					<th>Items</th>
				</tr>
			</thead>
			<tbody>
				<c:forEach var="cart" items="${carts}">
					<tr>
						<td>
							${cart.date}
						</td>
						<td>
							<c:forEach var="item" items="${cart.items}">
								${item.product.name}(${item.count}),
							</c:forEach>
						</td>
					</tr>
				</c:forEach>
			</tbody>
		</table>
	</div>

	<script type="text/javascript">
		function logout() {
			var form = document.createElement('form');
			form.setAttribute('method', 'post');
			form.setAttribute('action', 'logout');
			form.style.display = 'hidden';
			document.body.appendChild(form)
			form.submit();
		}
	</script>
</body>
</html>